﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace teacherplanner
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        
        private string SelectDBFile()
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter =
               "mdb files (*.mdb)|*.mdb|All files (*.*)|*.*";
            dialog.InitialDirectory = teacherplanner.Properties.Resources.DataPath;
            dialog.Title = "Select your database file";
            return (dialog.ShowDialog() == DialogResult.OK)
               ? dialog.FileName : null;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            int myw = this.Width;
            int myh = this.Height;
            this.panel1.SetBounds((int)(myw / 2)-150, (int)(myh / 2)-150, 300, 300);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            teacherplanner.CreateDbForm createDBForm = new teacherplanner.CreateDbForm();
            createDBForm.Show();
        }

        private void Form1_Resize(object sender, EventArgs e)
        {
            int myw = this.Width;
            int myh = this.Height;
            this.panel1.SetBounds((int)(myw / 2) - 150, (int)(myh / 2) - 150, 300, 300);
        }

        private void loadPlannerFormToolStripMenuItem_Click(object sender, EventArgs e)
        {
            teacherplanner.PlannerForm myForm = new teacherplanner.PlannerForm();
            myForm.Show();
        }

        private void loadDefineTimetableFormToolStripMenuItem_Click(object sender, EventArgs e)
        {
            teacherplanner.DefineTimetable myForm = new teacherplanner.DefineTimetable();
            myForm.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            teacherplanner.Properties.Settings.Default.CurrentPlanner = SelectDBFile();
            teacherplanner.PlannerForm myForm = new teacherplanner.PlannerForm();
            myForm.Show();
        }
    }
}
